package com.stxx.stiot2.controller;

import com.stxx.framwork.domain.R;
import com.stxx.framwork.domain.model.PageQuery;
import com.stxx.framwork.domain.model.PageResult;
import com.stxx.stiot2.domain.Alarm;
import com.stxx.stiot2.domain.EventLog;
import com.stxx.stiot2.service.EventLogService;
import com.stxx.stiot2.service.EventLogService;
import org.noear.solon.annotation.*;

import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Arrays;

@Controller
@Mapping("/event-log")
public class EventLogController {

    @Inject
    EventLogService baseService;

    @Get
    @Mapping("/list")
    public PageResult<EventLog> list(EventLog bo, PageQuery pageQuery) throws SQLException {
        PageResult<EventLog> r = baseService.pageList(bo,pageQuery);
        return r;
    }

    @Get
    @Mapping("/list-by-device-id")
    public PageResult<EventLog> listByDeviceId(String deviceId, PageQuery pageQuery) throws SQLException {
        PageResult<EventLog> r = baseService.pageListByDeviceId(deviceId,pageQuery);
        return r;
    }

    @Delete
    @Mapping("/{ids}")
    public R<Object> remove(@Path String[] ids) throws SQLException {
        baseService.deleteByIds(ids);
        return R.ok("数据删除成功");
    }
}
